import 'package:flutter/material.dart';
import 'package:gameplay_flutter/lib_basemodel/user/user.dart';
import 'package:gameplay_flutter/lib_baseview/widget/dialogs.dart';
import 'package:gameplay_flutter/lib_user/user_manager.dart';
import '../../../../lib_basemodel/chat_room/kh_chat_room_enter_model.dart';
import '../../../../lib_basemodel/chat_room/kh_chat_room_seat_on_model.dart';
import '../../../../lib_network/http_api.dart';
import '../../../../lib_network/http_helper.dart';
import '../../interface/chat_room_leaf_interface.dart';
import 'mic_seat_scene.dart';

class MicSeatWidgetModel extends ChatRoomChangeNotifier {
  MicSeatScene micSeatScene;
  // Channel? get channel => roomModel.channel;

  // User? get currUser => roomModel.currUser;

  KHChatRoomEnterModel? get roomEnterModel => roomModel.roomEnterModel;
  int? micCount;

  MicSeatWidgetModel({this.micSeatScene = MicSeatScene.ROOM}) {
    // initData();
    micCount = 9;
    print('MicSeatWidgetModel');
  }

  void changeMicCount(int newCount) {
    // setState(() {
    micCount = newCount;
    // });
    notifyListeners();
  }

  void quitMic(int position, String? roomNo) async {
    // roomModel.sendMessage(
    //   RoomConstant.MESSAGE_ID_QUIT_MIC,
    // );

    // var response = await HttpHelper.instance().post(
    //   HttpApi.roomMicHoldDown,
    //   body: {
    //     "roomNo": roomNo, // 房间号
    //     'userId': tmpUser!.id, // 用户id
    //     'index': position, // 麦位索引
    //     'status': -1, // 下麦
    //   },
    // );

    // if (!response.isSuccess) {
    //   throw Exception();
    // } else {
    //   KHChatRoomSeatOnModel seatDownModel =
    //       KHChatRoomSeatOnModel.fromJson(response.result);

    //   roomEnterModel?.micList = seatDownModel.roomMicInfos;

    //   notifyListeners();
    //   return true;
    // }
  }

  onMicSeatClick(BuildContext context, int position, String? roomNo) async {
    roomModel.roomPageModel?.joinMicAuto(context);
  }

  onMicSeatDownClick(BuildContext context, int position, String? roomNo) async {
    // roomModel.roomPageModel?.downMicAuto(context);
    roomModel.roomPageModel?.downMicAuto(context, roomNo, position);
  }
}
